﻿@using TaskoMask.BuildingBlocks.Contracts.ViewModels
@using TaskoMask.BuildingBlocks.Contracts.Dtos.Organizations

@foreach (var item in Model)
{
    <div class="col-12 mx-auto pb-3">
        <h6 id="@item.Organization.Id" data-toggle="tooltip" data-placement="left" title="@item.Organization.Description">
            <i class="bi bi-building"></i>
            @item.Organization.Name
            <a @onclick="@(()=>ShowUpdateOrganizationModal(item.Organization.Id))" class="text-warning" >
                <i class="bi bi-pencil"></i>
            </a>
        </h6>

        <TabNav Model="@item.Organization" />

        <div class="tab-content py-4">

            <div class="tab-pane active" id="boards-@item.Organization.Id" role="tabpanel">
                <div class="row">
                    <Tips Model="@item"></Tips>
                </div>

                @if (item.Projects.Any())
                {
                    <div class="row">
                        <TaskoMask.Clients.UserPanel.Shared.Boards Model="@item.Boards" OrganizationId=@item.Organization.Id />
                    </div>
                }


            </div>

            <div class="tab-pane" id="projects-@item.Organization.Id" role="tabpanel">
                <div class="row">
                    <Projects Model="@item.Projects" OrganizationId=@item.Organization.Id />
                </div>
            </div>

            <div class="tab-pane" id="reports-@item.Organization.Id" role="tabpanel">
                <div class="row">
                    <Reports Model="@item.Reports" />
                </div>
            </div>
        </div>
    </div>
}

@code {

    [Parameter]
    public IEnumerable<OrganizationDetailsViewModel> Model { get; set; }



    /// <summary>
    ///
    /// </summary>
    private void ShowUpdateOrganizationModal(string organizationId)
    {
        var parameters = new ModalParameters();
        parameters.Add(nameof(Pages.Organizations.Components.UpdateOrganization.Id), organizationId);
        ModalService.Show<Pages.Organizations.Components.UpdateOrganization>("Update Workspace", parameters, new ModalOptions {Class="blazored-modal w-75 w-md-50 bg-light-gray" });
    }
}
